package com.sss.controller;

import com.sss.pojo.User;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName HelloController
 * @Description TODO
 * @Author 沈世举
 * @Date 2020/12/8 13:27
 * @Version 1.0
 */
@RestController
public class HelloController {

    @GetMapping("/hello")
    public String hello(){

        return "hello";
    }

    /**只要我们的接口中，返回值存在实体类，他就会被扫描到Swagger中*/
    @PostMapping(value = "/user")
    public User user(){
        return new User();
    }

    /**Operation接口注释*/
    @ApiOperation("Hello2控制方法")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userName",value = "用户名",required = true,dataType = "String",paramType = "path")
    })
    @GetMapping(value = "/hello2/{userName}")
    public String hello2( @PathVariable("userName")String userName){
        return "hello"+userName;
    }

    /**Operation接口注释*/
    @ApiOperation("Post测试方法111")
    @PostMapping(value = "/hello3")
    public User hello3( @ApiParam("用户") User user){
        return user;
    }
}
